//
//  HeadView.m
//  Travel
//
//  Created by lanou3g on 15/11/18.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "HeadView.h"
#import "HeadModel.h"
//#import "SDCycleScrollView.h"


@interface UIView ()

//存放数据源的数组
@property (nonatomic,strong) NSMutableArray *sourcesArray;

//轮播图

//@property (nonatomic,strong)  SDCycleScrollView *sc;

@end


@implementation HeadView


-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self Layout];
    }
    return self;
}

-(void)Layout
{
    self.sourcesArray = [NSMutableArray new];
    //获取数据
    [self requestData];
    
    self.headView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    //添加到父视图
    //[self  addSubview:self.headView];
}

//请求数据

-(void)requestData
{
    NSString *url = @"http://api.breadtrip.com/hunter/products/more/?start=0";
    
    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
    
    NSMutableDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
    
    NSArray *product_listArr = jsonDic[@"product_list"];
    
    for (NSDictionary *tab_listDic in product_listArr) {
        
        HeadModel *hModel = [HeadModel new];
        
        [hModel setValuesForKeysWithDictionary:tab_listDic];
        
        [self.sourcesArray addObject:hModel];
        
        
    }
    
    
}

////轮播图的设置
//
//-(void)layoutLunBo
//{
//    //使用第三方
//    self.sc = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(10, 8, 352, 90) imagesGroup:nil];
//    //设置轮播图的属性
//    
//    self.sc.infiniteLoop = YES;//是否循环轮播
//    self.sc.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
//    //自定义轮播图的时间间隔
//    self.sc.autoScrollTimeInterval = 0.2;
//    self.sc.dotColor = [UIColor cyanColor];
//    
//    [self  addSubview:self.sc];
//    
//    [self.sc setImageURLStringsGroup:self.sourcesArray];
//    
//    
//}


@end
